package com.cz.basetool.ui_work.util.et_bind;


import android.util.Pair;

import com.cz.basetool.ui_work.util.txt.CZ_TextUtil;
import com.cz.basetool.ui_work.util.txt.RegularUtil;
import com.cz.basetool.ui_work.util.et_bind.base.BaseEditTextValidator;

/**
 * Created by 陈章 on 2017/4/12 0012.
 * func:
 * 车牌号码校验器
 * 1.大写
 */
public class CarNoValidator extends BaseEditTextValidator {
    private String provinceHead = "";
    public CarNoValidator() {
    }

    public CarNoValidator(OnValidatorResultObserver validatorResultObserver) {
        super(validatorResultObserver);
    }

    @Override
    public Pair validate(String txt) {
        String realTxt = provinceHead + txt;
        if(CZ_TextUtil.is_null_or_empty(realTxt)){
            return getEmptyTipPair();
        }

        boolean check = RegularUtil.check(realTxt, "^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z0-9]{1}[A-Z0-9]{1}([京津沪渝桂蒙宁新藏冀晋辽吉黑苏浙皖赣闽鲁粤鄂湘豫川云贵陕甘青琼])?[A-HJ-Z0-9]{1}[A-NP-Z0-9]{3}[A-NP-Z0-9挂学警港澳领试超外]{1}([A-HJ-NP-Z0-9外])?)|([A-Z0-9]{7})$");
        if(check == true){
            return  getRightPair();
        }else{
            return  getErrorPair("不合法");
        }
//
//        if(CZ_TextUtil.hasLowerLitter(realTxt)){
//            return getErrorPair("车牌号码不可包含小写字母");
//        }
//
//        return getRightPair();
    }

    public void setProvinceHead(String provinceHead) {
        this.provinceHead = provinceHead;
    }
}
